package cn.hjh.service;

import cn.hjh.dao.HibernateUtil;
import cn.hjh.dao.ProjectDao;
import cn.hjh.pojo.Project;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;

public class ProjectBiz {
    private ProjectDao projectDao = new ProjectDao();

    //    添加项目的时候同时添加员工
    public void addNewProject(Project project){
        Transaction tx = null;
        try {
            tx = HibernateUtil.currentSession().beginTransaction();
            projectDao.save(project);
            tx.commit();
        } catch (HibernateException e) {
            e.printStackTrace();
            if (tx != null)
                tx.rollback();
        }
    }
}
